package com.itheima.aop;

import lombok.extern.slf4j.Slf4j;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Slf4j
@Component
//@Aspect  //AOP类
public class TimeAspect {
//    @Around("execution(* com.itheima.service.*.*(..))") //切入点表达式
    @Around("com.itheima.aop.MyAspect1.pt()")
    public Object recordTime(ProceedingJoinPoint joinPoint) throws Throwable {
        long begin = System.currentTimeMillis();    //记录开始时间
        Object result = joinPoint.proceed();//调用原始方法
        long end = System.currentTimeMillis();  //结束时间

        log.info(joinPoint.getSignature()+"方法执行的耗时{}ms",end-begin);
        return result;
    }
}
